Repository navigation
Checks and scale updates read only iterates the AA safeguard has vetted - #566
Merged
Merged
Conversation
The dual step and the AA safeguard now come before the convergence check. When the safeguard rejects the AA step of an iteration with a check due, the scale update and the refinement tolerance run at the next iteration instead, on the plain DR step from the restored v. That iteration never carries an AA step, because a rejection resets AA, so the wait is exactly one iteration for every acceleration_interval, acceleration_lookback and AA type. The update is paced by the iteration it was due at, so the RESCALING_MIN_ITERS cadence is unchanged. Before, update_scale read the iterate of a step the safeguard would go on to reject. An applied update reset AA, the safeguard then had nothing to test, and v was rebuilt from that iterate, so the step was kept untested. On HUESTIS this failed 71 of 82 runs with QDLDL. update_scale remaps v and takes the dual step again (the remap does not read v). Where no check meets a rejected step the iterates are unchanged bit for bit. The convergence and time-limit tests still read the scheduled iteration; the next commit moves them too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The whole check now waits: the convergence and time-limit tests, the refinement tolerance, the verbose print and the scale update run at the next iteration when the safeguard rejects the AA step of an iteration with a check due. One check reads one iterate: a rejected step is never returned as a solution and never counts toward the consecutive checks a certificate must pass (CERT_PERSISTENCE_CHECKS). The print moves into the check, so verbose never computes the residuals of a rejected step (the next solve's CG tolerance reads them). glbopts.h now requires PRINT_INTERVAL to be a multiple of CONVERGED_INTERVAL, which both settings of it are. Tradeoff: a rejected step whose iterate would have passed the convergence test is not returned; the solve continues from the restored v and stops at a later check. This is a separate commit so that it can be measured (and dropped) on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The last iteration's iterate is returned at max_iters. A rejected AA step there could not wait for a vetted iterate as the check now does, so no step is proposed there and no scheduled check is lost. This changes a run only when max_iters - 1 is a multiple of acceleration_interval: always at interval 1, never at the default max_iters and interval 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test/problems/test_aa_vetted.h, on scaled-down copies of HUESTIS (n = 10,000 is HUESTIS itself). The CSV log gives each iteration's scale and AA counts. - test_aa_vetted_structure: on every solve the scale changes only at a check on a vetted iterate, a solve stops only at one, and the iteration after a rejected step carries none (hard asserts, any trajectory). Both sides of the verdict must occur over 42 solves: checks that waited for a rejected step (never before the change), and scale changes at an accepted step, also at acceleration_interval 1. - test_aa_vetted_last_iter: no AA step at the last iteration when max_iters - 1 is a multiple of the interval. - test_aa_vetted_repeat: two solves on one workspace with scs_update. - test_aa_vetted_huestis (QDLDL): n = 3,000 from four starts solves within 15,000 iterations and 30 scale updates. Before the change these took 17,475 to 22,600 iterations with 66 to 100 updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acceleration.rst (Safeguarding): the safeguard judges each step before anything reads the iteration; a check whose iteration's step is rejected runs at the next iteration; no step at the last iteration; the refinement switch is the one decision still made on an unvetted iterate; what went wrong before (HUESTIS). scale.rst: the sample and the decision read vetted iterates, pacing is counted from the iterations the checks were due at, and the AA reset at an update comes after the safeguard's test. index.rst (termination): tests read vetted iterates only, so a solve can stop one iteration after a multiple of 25. info.rst: the safeguard now tests every AA step, including at the stopping iteration and at a scale update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same 82 runs per solver as the diagnosis: 0 of 82 fail with QDLDL (71 before), 1 with CPU CG with deflation (5), 2 with GPU CG with deflation (12), 1 with plain CPU CG (0); none oscillates, and the CPU failures solve with a larger budget. Comment only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #563 (the CG tolerance is saved at the checks, set_cg_tol_res), #562 and #564 (nine benchmark problems) and #565 (SCS_INDETERMINATE at the limit, SCS_FAILED for a non-finite iterate). Conflicts: - src/scs.c, end of the loop: master reworded the comment above the CSV log, next to the old dual step and AA safeguard, which this branch moved ahead of the check. Kept the branch's order and master's comment. - test/run_tests.c: MU_TOTAL_TESTS 127 (master's 123 and the four test_aa_vetted tests; 127 mu_run_test calls). Interactions checked: - set_cg_tol_res merged into the check next to set_refine_tol, so a check that waits for the AA safeguard saves the CG tolerance at the iteration it runs, from the vetted iterate; finalize keeps its call. Without logging the CG solves read what they read on the branch before (the residuals of the last check that ran), so no unlogged iterate changes. Comments at the safeguard and at set_cg_tol_res say so. - The verbose print stays inside the check; its comment no longer gives the CG tolerance as the reason (it now reads a saved value). - CSV logging still does not change the iterates (test_csv_log passes): the AA safeguard reads v, and the check computes its own residuals. With #563 the logged CG trajectories in test_aa_vetted.h are the unlogged ones, so its comment on logging and its CG counts are updated (re-measured on macOS arm64, master eeef310 for "before"). - #565's set_unfinished judges the last iterate, which carries no AA step (a789a20), and a time-limit stop comes from a check, which reads only vetted iterates. No code change. - #559's rollback inside update_scale is as before the merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e limit The CG tolerance (#563) is now set at the checks, so it reads only iterates the AA safeguard has accepted: say so where acceleration.rst lists what a check does, and in linear_solver that the last check can be one iteration after a multiple of 25. The status at max_iters or time_limit_secs (#565) is judged on a last iterate that never comes from a rejected AA step (exit_flags). time_limit_secs can be overrun by 26 iterations, not 25, when a check waits (settings, twice). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repeat test checks that the structure holds in each of two solves on one workspace. It also asserted that both solve in double precision, which is not what it tests and depends on the BLAS and LAPACK: with the dense solver, CI's MKL (Linux) and Accelerate (macOS arm64) runners did not solve the problem at acceleration_interval 1 within its 5,000 iterations, while every backend on an Apple M-series Mac solved both solves from 41 starts, with Accelerate and with OpenBLAS. The exit flags and iterations are now printed instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dense solver refactors an n x n matrix at every scale update, and the three tests that read the CSV log made its suite about 9 times as long (10.6 s against 1.2 s on an Apple M-series Mac; 1.0 s now). CI's valgrind job did not finish run_tests_dense within its 60 minutes and was cancelled. The code these tests check, in src/scs.c, is the same for every linear solver; QDLDL, CPU CG, GPU CG, Accelerate and MKL Pardiso still run them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every 25 iterations SCS runs a check: the convergence and time-limit tests, the tolerances the linear solves read until the next check (refinement's, and CG's since #563), the verbose print, and the scale update (its sample and its decision). The check now reads only iterates the Anderson acceleration (AA) safeguard has accepted. The safeguard runs right after the dual step, before the check. When it rejects the step of an iteration with a check due, the check runs at the next iteration instead, which never carries an AA step. AA also makes no step at the last iteration, whose iterate is returned. There is no new setting and no API or ABI change, and the change is deterministic (the safeguard's verdict is a function of the iterates).
Decision (maintainer): 2026-11-25, "Measure the fix" (the pre-registered A/B below). 2026-11-26, "adopt x7" (x7 is this design).
Merged with master (eeef310: #563, #562, #564, #565). See "Merge with master" below.
Why: HUESTIS
HUESTIS (Maros-Meszaros) failed 71 of 82 runs with QDLDL: eps 1e-4 and 1e-6, 41 initial scales each (the default moved by 0 to 40 ulps), 22,600 iterations, every status verified independently at 10 x eps. The diagnosis traced every link of the chain:
acceleration_interval5, every check is an AA iteration. The check andupdate_scaleread the iterate built from that iteration's AA step before the safeguard judged it. Through the rail the largest change of the per-row multipliers sits 4% below the update threshold, so a large step can push it over, andupdate_scalethen applies a diagonal-only update.This order dates from SCS 3.1.0: 2c4bde5 moved the safeguard after the check, and 5a40b44 (#198) moved
update_scaleahead of the dual step.What changes
scs_solve): AA (aa_apply, wheni % acceleration_interval == 0andi + 1 < max_iters), the DR step,compute_rsk, then the dual step (moved up from afterupdate_scale), then the AA safeguard whenever AA ran this iteration (it tests only when AA made a step), then the check.i % CONVERGED_INTERVAL == 0. If the safeguard rejected that iteration's step, the check runs at the next iteration. A rejection resets AA and the firstaa_applyafter a reset only records the iterate, so that iteration carries no step, for everyacceleration_interval,acceleration_lookbackand AA type. A check therefore waits exactly one iteration, and it reads the plain DR step from the v the safeguard restored.max_iters - 1is a multiple ofacceleration_interval(always at interval 1; never at the defaultmax_itersand interval 5).update_scalegetscheck_iter, the iteration the check was due at, so the cadence ofRESCALING_MIN_ITERSand the samples per update are unchanged. Its rollback (Scale update: roll back when the solve for g fails its check #559) is unchanged: it returns before the remap, as before.update_scaleremaps v (v = rsk / R + 2 u_t - u, which does not read v) and then takes the dual step again (update_dual_vars), so an applied update gives the arithmetic of remapping and then stepping (one axpy more per applied update).CERT_PERSISTENCE_CHECKS). A solve can stop at an iteration one after a multiple of 25.PRINT_INTERVAL);include/glbopts.hnow requiresPRINT_INTERVALto be a multiple ofCONVERGED_INTERVAL(#error). Both builds' values are (250 and 25 by default, 1 and 1 withVERBOSITY > 0).solve_direct,solve_indirectat multiples ofREFINE_CHECK_INTERVAL): it judges the iteration's linear solve, which comes before the safeguard can judge the step.info.rst).Tradeoff: no solve is added. At a check whose iteration's step is rejected, the check, and with it termination and the scale update, comes one iteration later. A rejected step whose iterate would have passed the convergence test is not returned: the solve continues from the restored v and stops at a later check.
Docs:
algorithm/acceleration.rst(Safeguarding),algorithm/scale.rst(when the procedure runs, pacing, the reset after the safeguard),algorithm/index.rst(termination),api/info.rst(counters),api/exit_flags.rst(the last iterate at the limit),api/settings.rst(the time limit can be overrun by 26 iterations),linear_solver/index.rst(the CG tolerance's check).Results
HUESTIS
Verified failures of 82 runs (eps 1e-4 and 1e-6 x 41 initial scales, 22,600 iterations, no time limit; 64-bit ARM Linux, NVPL, CUDA 13.0, one thread per run). M = master 1dd2a7e, V = this branch before the merge (a789a20's library code). "Oscillating" means more than 10 scale updates. "Railed" means at most 10: the run is still on the rail.
DEFLATE_VECTORS=0)None of V's failures oscillates. Each is a railed run that solves later: with 100,000 iterations every one solves, by 30,025 iterations, with 10 scale updates. In the traced CPU run (1e-4, 11 ulps) kappa jumps 37-fold right after an AA step that the safeguard accepted. That is the diagnosis's "railed" mode, which this change does not address.
Pre-registered A/B
M = master 1dd2a7e, V = this branch before the merge (08bfdbb). The predictions, sets, budgets and decision rule were registered before any run. The sets: the 492 box-cone problems (QDLDL; 320 of them also with CPU CG: the 469 that the earlier A/Bs' CPU CG set does not already hold, less the 149 the pilot's budget rule excluded), 86 SDPs (SDPLIB, QDLDL), and the sets of the earlier eigCG and GPU A/Bs (QDLDL, CPU CG, GPU CG), at eps 1e-4 and 1e-6, in 2,602 scored units. Every status is verified independently at 10 x eps (promote; on the box-cone set and the SDPs, a run over its time limit counts as unsolved). Every unit whose outcome flipped between the arms, or varied across starts, was run from 9 starts per arm. An independent re-derivation from the raw records reproduces every number below.
The regression pattern, and its cause
The losses are concentrated, reproducible across starts, and have one cause. On some problems V's safeguard rejects nearly every AA step, so V runs as plain Douglas-Rachford. M was faster there because it kept some AA steps untested at scale-update iterations, which is the path this change closes. On HUESTIS the untested steps did the harm; on these problems they helped.
max_iters. The SDP set still nets +1.78 for V, from hinf (+24 over 9 starts) and arch (+13).acceleration_interval1 (not the default; information only): HUESTIS solves 82 of 82 on both arms, but in a median of 5,750 iterations against 450 with QDLDL, and 3,550 against 300 with CPU CG.So after this change AA contributes little on these problems. The safeguard's rejection test is where to look next; this PR does not change it.
Merge with master
Merged eeef310 (merge commit 7b104c3, no rebase). Conflicts:
src/scs.c, end of the loop: master reworded the comment above the CSV log, next to the old dual step and AA safeguard, which this branch moves ahead of the check. The branch's order and master's comment are kept.test/run_tests.c:MU_TOTAL_TESTSis 127 (master's 123 plus the four new tests; 127mu_run_testcalls).Interactions checked:
set_cg_tol_res: it runs in the check next toset_refine_tol, so a check that waits saves the CG tolerance at the iteration it runs, from the vetted iterate.finalizekeeps its call. Without logging, the CG solves read what they read on the branch before the merge (the residuals of the last check that ran), so no unlogged iterate changes. Comments at the safeguard and atset_cg_tol_ressay so.test_csv_logpasses on every build). The AA safeguard reads v, and the check computes its own residuals. With Logging to CSV no longer changes CG's iterates #563 the logged CG trajectories oftest_aa_vetted.hare the unlogged ones, so that file's comment on logging and its CG counts were updated (re-measured; "before" figures on eeef310).set_unfinished: it judges a last iterate that never comes from a rejected AA step. Atmax_itersthe last iteration carries no step, and a time-limit stop is made at a check.exit_flags.rstsays so. No code change.update_scaleis unchanged.Re-run on the merged head (64-bit ARM Linux, NVPL; library code of 7b104c3 = the head):
max_iters(issue_220 at 1e-6 with CPU CG, tau > 0, "solved (inaccurate)" as before), and it is identical too.scs_initon the remaining 2 (S_102, not scored).DLONG, 112 units): 107 of 107 that stopped before the 222 s time limit. The other 5 hit the limit on both.Tests
test/problems/test_aa_vetted.h, 4 tests. The problems are scaled-down copies of HUESTIS built in the test: minimize ||x||^2 subject to two dense rows and x >= 0. Each solve's CSV log gives, per iteration, the scale and the AA counts.test_aa_vetted_structurechecks structure that holds on any trajectory. The scale changes only at a check: at a multiple ofCONVERGED_INTERVALwhose step was not rejected, or one iteration after one whose step was. The iteration after a rejected step carries no step. A converged solve stops at such a check. There is no step at iterationmax_iters - 1. It runs 42 solves at intervals 1, 2, 3 and 5. It also asks that at least one check waited and changed the scale, and that the scale changed at an accepted step at least once (also at interval 1). On the Mac with QDLDL: 34 and 22 at interval 1, 15 and 12 at the others.test_aa_vetted_last_iter:max_iterswith(max_iters - 1) % interval == 0at intervals 1, 3 and 5 (17 solves).test_aa_vetted_repeat: two solves on one workspace, the second afterscs_update: the structure holds in each. Whether they solve is printed, not checked (9562ee4; the first push asserted it). At interval 1 the dense solver on CI's MKL (Linux) and Accelerate (macOS) runners did not solve it within the test's 5,000 iterations, while every backend on an Apple M-series Mac solved both solves from 41 starts.test_aa_vetted_huestis(QDLDL, double precision): n = 3,000 at eps 1e-4 and 1e-6 from two initial scales must solve within 15,000 iterations and 30 scale updates (this branch: at most 5,225 and 12).The three tests that read the CSV log skip the dense solver (9e8a47a). It refactors an n x n matrix at every scale update: they made its suite about 9 times as long (10.6 s against 1.2 s on the Mac), and the first push's valgrind job was cancelled at its 60-minute limit in
run_tests_dense. The code they check is the same for every linear solver.Master (eeef310) fails three of the four.
structureandlast_iterfail with QDLDL and with CPU CG: AA makes a step at the last iteration of a solve that ran out (inlast_iter's 17 solves, 9 with QDLDL and 7 with CG).huestisfails because its first solve is not solved within 15,000 iterations: master returns "infeasible (inaccurate - reached max_iters)" after 58 scale updates.repeatpasses on master.Builds on the merged head (7b104c3; 9562ee4 and 9e8a47a change only
test_aa_vetted.hand were re-run on the Mac), all passing:SFLOAT=1,USE_LAPACK=0,DEFLATE_VECTORS=0,DLONG=1,NO_PRINTING=1andNO_READ_WRITE=1; CMake with ctest.VERBOSITY=1,test_box_t_weight_stopfails, as it does on master eeef310.Not measured
🤖 Generated with Claude Code